<template>
	<view>
		   <view class="oldaddress">
		       <view class="ads-flex-between">
		           <view>{{address.realName}}</view>
		           <tel>{{address.mobile}}</tel>
		       </view>
		       <view class="building">
		           {{address.provincename}} {{address.cityname}} {{address.countyname}} {{address.address}}
		       </view>
		   </view>
		   <view v-for="(item,index) in mallDetail.buyItemlist" :key="index" class="pList_box">
				<view class="pList">
					<view class="pList_left" ><image :src="`${uniConfig.ssoPath + item.logo}`" /></view>
					<view class="pList_right">
						<view style="font-weight: 600;">{{item.productName}}</view>
						<view style="margin-top:16rpx;">单价：<text class="pList_text">￥{{item.costPrice}}</text></view>
						<view >数量：{{item.qty}}</view>
					</view>
				</view>
				<view class="yt-list-cell b-b">
					<text class="cell-tit clamp">商品总额</text>
					<text class="cell-tip">￥{{ item.totalAmount }}</text>
				</view>
				<view class="yt-list-cell b-b">
					<text class="cell-tit clamp">商品数量</text>
					<text class="cell-tip">￥{{ item.qty }}</text>
				</view>
				<view class="yt-list-cell b-b">
					<text class="cell-tit clamp">优惠金额</text>
					<text class="cell-tip red">-￥{{ item.discount }}</text>
				</view>
				<view class="yt-list-cell b-b">
					<text class="cell-tit clamp">备注</text>
					<text class="cell-tip">{{ item.memberRemark }}</text>
				</view>
			</view>
			<view class="pListbot">
				<view style="padding:0 0 32rpx 0;font-weight: bold;">订单明细</view>
				<view class="yt-list-cell b-b">
					<text class="cell-tit clamp">订单总额:</text>
					<text class="cell-tip red">￥{{mallDetail.orderTotalAmount}}</text>
				</view>
				<view class="yt-list-cell b-b">
					<text class="cell-tit clamp">优惠金额:</text>
					<text class="cell-tip red">-￥{{mallDetail.discount}}</text>
				</view>
				<view class="yt-list-cell b-b">
					<text class="cell-tit clamp">实付金额:</text>
					<text class="cell-tip red">￥{{mallDetail.amount}}</text>
				</view>
				<view class="yt-list-cell b-b">
					<text class="cell-tit clamp">订单号码:</text>
					<view class="cell-tip"><view style="display:flex;">{{mallDetail.tradeno}}<uv-tags text="复制" plain size="mini" type="warning" @click="copyOrder" style="margin-left: 32rpx;"></uv-tags></view></view>
				</view>
				<view class="yt-list-cell b-b">
					<text class="cell-tit clamp">下单时间:</text>
					<text class="cell-tip">{{mallDetail.addTime}}</text>
				</view>
				<view class="yt-list-cell b-b">
					<text class="cell-tit clamp">支付时间:</text>
					<text class="cell-tip">{{mallDetail.paymentTime}}</text>
				</view>
				<view class="yt-list-cell b-b">
					<text class="cell-tit clamp">订单状态:</text>
					<text class="cell-tip">{{mallDetail.payStatus == 'S'?'已支付':'待支付'}}</text>
				</view>
				<view class="yt-list-cell b-b" v-if="mallDetail.expressStatus">
					<text class="cell-tit clamp">物流状态:</text>
					<text class="cell-tip">{{expressStatus[mallDetail.expressStatus]}}</text>
				</view>
			</view>
			<view class="submitBt bg-line-color" v-if="mallDetail.payStatus == 'N'" @click="goPay">去支付</view>
			<view class="lastchild"></view>
		</view>
</template>

<script setup lang="ts">
const app = getApp()
import { ref,getCurrentInstance } from 'vue'
import { getMallDetail } from "@/api/product"
import { onLoad } from "@dcloudio/uni-app"
import { uniConfig } from '@/config/index'
import { getAddressList , delAddress } from '@/api/product'
const goPay = () => {
	uni.navigateTo({
		url:`/pages/mall/orderConfirm?tradeno=${mallDetail.value.tradeno}`
	})
}
const expressStatus = ref<any>({
	wait:"待发货",
	send:"已发货",
	send_part:"部分发货",
	receive:"已收货",
	notify_send:"通知发货中",
	refund:"已退款",
	wait_refund:"等待退款",
	ing_refund:"退款处理中"
})
const copyOrder = () => {
	uni.setClipboardData({
		data:mallDetail.value.tradeno,//要被复制的内容
		success:()=>{//复制成功的回调函数
		uni.showToast({//提示
			title:'复制成功'
		})
		}
	})
}
const mallDetail = ref<any>([])
let address = ""
onLoad(async (options : any) => {
	const { proxy } = getCurrentInstance()
	await proxy.$onLaunched
	console.log("otions",options)
	getMallDetail(options).then(res=>{
		if(res.success){
			mallDetail.value = res.data
			console.log("mall123",mallDetail)
		}
	})
	getAddressList({page_no:1,per:100}).then(res => {
		let saveAdd = res.data.records.filter((val)=>{
			return val.defaultAddress=='Y'
		})
		address = saveAdd[0];
		console.log("res.data.records",address);
	})
})
	 
</script>

<style lang="scss">
.mallIndex{
	margin-top:12vh;
}
.pList_box{
	width: 92%;
	margin: 32rpx auto 0;
	border-radius: 9px;
	overflow: hidden;
	background: #fff;
	box-shadow: 0 0px 12px rgba(0,0,0,.1);
	padding:32upx;
	box-sizing: border-box;
}
.pList{
	display: flex;
	align-items: center;
	width:100%;
	border-bottom: 1px solid #eee;
    padding-bottom: 32rpx;
    margin-bottom: 32rpx;
}
.pListbot{
	width: 92%;
	display: flex;
	flex-direction: column;
	margin: 32rpx auto 0;
	border-radius: 9px;
	overflow: hidden;
	background: #fff;
	box-shadow: 0 0px 12px rgba(0,0,0,.1);
	align-items: left;
	padding:32rpx;
	box-sizing: border-box;
	line-height: 2;
	
}
.lastchild{
	margin-bottom:32rpx;
}
.pList_right{
	padding-left:32rpx;
}
.pList_left image{
	width: 200rpx;
	height: 200rpx;
	border-radius: 9px;
}
.pList_text{
	color: #d2553d;
	font-weight: 600;
} 
.swiper-box{
	width:90%;
	margin-left:5%;
	height:400rpx;
	border-radius: 9px;
	overflow: hidden;
}
.swiper-item image{
	width:100%;	
}
.oldaddress {
	padding: 32rpx;
	box-sizing: border-box;
	margin:32rpx auto 0;
	width:92%;
	border-radius: 9px;
	background-color: #fff;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	text{
		font-weight: bold;
		margin-bottom:16upx;
	}
}
.ads-flex-between {
	display: flex;
	align-items: center;
	font-size: 15px;
	font-weight: 500;
}
.building {
	margin-top: 6px;
	font-size: 14px;
	color: black;
}
.yt-list-cell {
    display: flex;
    align-items: center;
    line-height: 2;
    position: relative;
	font-size: 26upx;
    .cell-tit {
        flex: 1;
        color: #999;
    }
    .cell-tip {
        font-size: 28upx;
        color: $font-color-dark;
        &.red{
            color: $base-color;
        }
    }
}
.submitBt{
	position: fixed;
	bottom: 5%;
	width: 92%;
	left: 4%;
	height: 82rpx;
	text-align: center;
	line-height: 82rpx;
	border-radius: 42px;
	font-size: 32rpx;
	font-weight: 600;
	background: linear-gradient(90deg, #F20100 0%, #FD4E16 100%);
	color: #fff;
}
</style>